package behavioral_pattern.command_pattern;

public class Invoker {
    private Command command;

    public Invoker(Command command){
        this.command = command;
    }

    public void setCommand(Command command) {
        this.command = command;
    }
    public void call(){
        command.execute();
    }

}
abstract class Command{
    public abstract void execute();
}

class ConcreteCommand extends Command{
    private Receiver receiver;

    public void setReceiver(Receiver receiver) {
        this.receiver = receiver;
    }

    public ConcreteCommand(Receiver receiver) {
        this.receiver = receiver;
    }

    @Override
    public void execute() {
        receiver.action();
    }
}
class Receiver{
    public void action(){
        System.out.println("接收者执行操作1");
    }

}